---
-- Copyright (C)2017 CD Projekt Red. All Rights Reserved.
---

-- globals commProtocol

commProtocol_location = '../../../temp/' .. _ACTION .. '/common/commProtocol'

-- files commProtocol

commProtocol_files = {
	["src/protocols"] = {
		"src/test.proto",
		"src/interop.proto",
		"src/services.proto",
		"src/utility.proto",
		"src/scriptDatabase.proto",
		"src/scripts.proto",
		"src/private.cpp"
		},
	["include"] = {
		"include/commProtocolPublic.h" },
	["include/common"] = {
		"include/protoTypes.h",
		"include/protoStaticString.h" },
	["src"] = {
		"src/build.h",
		"src/build.cpp",
		"src/commProtocolInit.cpp" },
	["include/serialization"] = {
		"include/protoWriter.h",
		"include/protoReader.h" },
	["include/message"] = {
		"include/message.h" },
	["src/message"] = {
		"src/message.cpp" },
	["NEW_FILES"] = {
		"include/commProtocolApi.h" }
	}

-- configs commProtocol

project "commProtocol"
	filter "platforms:not x64_DLL"
		kind "StaticLib"
	filter "platforms:x64_DLL"
		kind "SharedLib"
	filter {}

	language "C++"
	location(commProtocol_location)
	rules { "ProtoScript" }

	pchheader "build.h"
	pchsource "src/build.cpp"

	includedirs { "./", "src", "include" }

	uses {
		"commProtocol",
		"redContainers",
		"redMemory"
	}

	vpaths(commProtocol_files)

	files(seq(commProtocol_files))

	filter "system:Linux"
		-- it seems this version of premake ignores cleancommands
		cleancommands {
			"{RMDIR} %{wks.location}/../gen/commProtocol"
		}
		prebuildcommands {
			-- "{RMDIR} %{wks.location}/../gen/commProtocol",
			"{MKDIR} %{wks.location}/../gen/commProtocol",
			-- "[ -d %{wks.location}/../gen/commProtocol ] || mkdir %{wks.location}/../gen/commProtocol",
			"%{wks.location}/../../internal/CommLibProtocol/bin/proto.elf cpp \"%{wks.location}/../../src/common/commProtocol/src/\" \"%{wks.location}/../gen/commProtocol/protocol/\""
		}
	filter {}
usage "commProtocol"
	-- we have to put explicite project name in gen dir path  because %{prj.name} is set from project where usage was used 
	includedirs { "%{wks.location}/../gen/commProtocol/protocol/" }